package com.chatplus.application.service.file.impl;

import com.chatplus.application.common.logging.SouthernQuietLogger;
import com.chatplus.application.common.logging.SouthernQuietLoggerFactory;
import com.chatplus.application.domain.entity.file.SysOssEntity;
import com.chatplus.application.domain.vo.file.UpLoadFileVo;
import com.chatplus.application.enumeration.FileChannelEnum;
import com.chatplus.application.file.FileAutoConfiguration;
import com.chatplus.application.service.file.FileService;
import com.chatplus.application.service.file.SysOssService;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.util.UriComponentsBuilder;

import java.io.InputStream;
import java.net.URI;

/**
 * @author lingyuan
 */
@Service("fileServiceLocal")
public class LocalFileServiceImpl extends FileService {

    private static final SouthernQuietLogger LOGGER = SouthernQuietLoggerFactory.getLogger(LocalFileServiceImpl.class);
    private final SysOssService sysOssService;
    private final String contextPath;
    public LocalFileServiceImpl(SysOssService sysOssService
                           , FileAutoConfiguration.FileProperties fileProperties
            , ServerProperties serverProperties) {
        super(fileProperties);
        this.sysOssService = sysOssService;
        this.contextPath = serverProperties.getServlet().getContextPath();
    }

    /**
     * 上传文件远程调用SDK
     */
    @Override
    public UpLoadFileVo uploadFile(MultipartFile scrFile) {
        return null;
    }
    @Override
    public InputStream getInputStream(Long id) {
        return sysOssService.getFileInputStream(id);
    }

    @Override
    public SysOssEntity getByHashId(String hashId) {
        return sysOssService.getByHashId(hashId);
    }

    @Override
    public FileChannelEnum getUploadChannel() {
        return FileChannelEnum.LOCAL;
    }
}
